package gwtmodule1.client.gui;

import gwtmodule1.client.HelloWorld;
import gwtmodule1.client.HelloWorldAsync;
import gwtmodule1.client.gui.utils.FormTable;
import gwtmodule1.client.gui.utils.FrameClient;
import gwtmodule1.client.gui.utils.HSpacer;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class PageHome extends VerticalPanel implements FrameClient {

	private HTML sessionid = new HTML();

	public PageHome() {
		super();
		HelloWorld.Util.getInstance().getHelloWorldMSG("xxx",
				new AsyncCallback() {
					public void onFailure(Throwable caught) {
						sessionid.setHTML("Could not get SessionID: "
								+ caught.getMessage());
					}

					public void onSuccess(Object result) {
						sessionid.setHTML(result.toString());
					}
				});

		setWidth("100%");
		setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		add(new HTML(
				"<br><br><center><b>Welcome to QAY Online Store.</b></br>YOUR place to spend money.</center>"));
		add(sessionid);
		add(new HSpacer());
		add(createLoginForm());
	}

	private Widget createLoginForm() {
		FormTable form = new FormTable();
		form.addInput("Username", new TextBox());
		form.addInput("Password", new PasswordTextBox());
		form.addButton("Login", null);
		return form;
	}

	public void onShow(Object param) {
	}

}
